#include "mng_explosion.h"

MNG_EXPLOSION::MNG_EXPLOSION(QPointF start_point,CASH *cash):QGraphicsProxyWidget()
{    
    lbl = new QLabel();
    int rand = 1 + qrand()%(3);

    movie = cash->cash_mng->value("Res/explosions/mng/" + QString::number(rand) + ".mng");

    movie->setCacheMode(QMovie::CacheAll);
    movie->start();

    lbl->setAttribute(Qt::WA_TranslucentBackground);
    lbl->setMovie(movie);

    this->setWidget(lbl);
    this->setPos(start_point);

    this->show();

    connect(movie, SIGNAL(finished()), this, SLOT(slot_anim_finished()));
}

MNG_EXPLOSION::~MNG_EXPLOSION(){}


QPainterPath MNG_EXPLOSION::shape() const
{
    return QPainterPath();
}


void MNG_EXPLOSION::slot_run()
{
    this->setPos(this->pos().x(), this->pos().y() + 10);
}


void MNG_EXPLOSION::slot_anim_finished()
{
    //this->setVisible(false);
    this->deleteLater();
    this->movie->jumpToFrame(1);
}
